package com.rock.platform.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SHA1 {
	public static byte[] ComputeHash(byte[] bytSource)
			throws NoSuchAlgorithmException {
		MessageDigest md = MessageDigest.getInstance("SHA-1");
		md.update(bytSource);

		return md.digest();
	}

	public static byte[] ComputeHash(String strSource)
			throws UnsupportedEncodingException, NoSuchAlgorithmException {
		byte[] bytSource = strSource.getBytes("UTF-16LE");

		return ComputeHash(bytSource);
	}
}
